package cn.itlaobing.dao;

import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;

/**
 * Created by Berlin-IOU on 2017/11/9.
 */
public class BaseDao {
    private static final String DB_URL="jdbc:mysql://localhost:3306/train";
    private static final String DB_USERNAME="root";
    private static final String DB_PASSWORD="root";
    private static final String DB_DRIVER="com.mysql.jdbc.Driver";
    private DataSource dataSourc=null;

    protected DataSource getDataSource() {
        if(dataSourc!=null){
            return dataSourc;
        }
        DruidDataSource dataSource=new DruidDataSource();
        dataSource.setUrl(DB_URL);
        dataSource.setUsername(DB_USERNAME);
        dataSource.setPassword(DB_PASSWORD);
        dataSource.setDriverClassName(DB_DRIVER);
        this.dataSourc=dataSource;
        return dataSource;
    }
}

